{{ define "content" }}

{{ $termName := .Data.Plural }}
{{ $terms := .Data.Terms.ByCount }}
{{ $length := len $terms }}
{{ $type := .Type }}

{{ if and $.Site.Taxonomies.tags (eq $termName "tags") }}
<article class="article article-tags post-type-list" itemscope="">
  <header class="article-header">
    <h1 itemprop="name" class="hidden-xs">标签</h1>
    <p class="text-muted hidden-xs">共 {{ $length}} 个标签</p>
    <nav role="navigation" id="nav-main" class="okayNav">
        <ul>
        <li><a href="/tags">All</a></li>
            {{ range $.Site.Taxonomies.tags.ByCount }}
              {{ if .Name }}
                <li><a href="/tags/{{ .Name | urlize}}/"> {{ .Name }}</a>
              {{ end }}
            {{ end}}
        </ul>
    </nav>
  </header>
  <!-- /header -->
  <div class="article-body">
    {{ range $terms }}
        {{ $term := .Term }}
        {{ $pages := .Pages }}
        {{ with $.Site.GetPage "taxonomy" (printf "%s/%s" $type $term) }}
        <h3 class="panel-title mb-1x">
            <a href="/tags/{{ .Name }}" title="#{{ $term }}"># {{ $term }}</a>
            <small class="text-muted">(Total {{ len $pages }} articles)</small>
        </h3>
        <div class="row">
        {{ range $pages }}   
            <div class="col-md-6">
                <article class="panel panel-default hover-shadow hover-grow" itemscope itemtype="http://schema.org/BlogPosting">
                    <div class="panel-body">
                        <div class="article-meta">
                            <time>{{.Date.Format  "2006-01-02" }}</time>
                        </div>
                    <h3 class="article-title" itemprop="name">
                        <a class="article-link" href="{{ .URL }}">{{ .Title }}</a>
                    </h3>
                    </div>
                    {{ if .Params.tags }}
                        <div class="panel-footer">
                        {{ range (first 3 .Params.tags) }}
                            <a href="/tags/{{ . }}" class="label label-default mb"> {{ . }}</a>
                        {{ end }}
                        {{ if gt (len .Params.Tags) 3}}
                        <span class="label label-default mb">···</span>
                       {{ end }}
                        </div>
                    {{ end }}
                </article>
            </div>
        {{ end }}
        </div>
        {{ end }}
        {{ end }}
    </div>
</article>
{{ end }}
{{ if and $.Site.Taxonomies.categories (eq $termName "categories") }}
<article class="content article article-categories article-type-list" itemscope="">
    <header class="article-header">
        <h1 itemprop="name" class="hidden-xs">分类</h1>
        <p class="hidden-xs">共 {{ len .Data.Pages }} 个分类</p>
        <nav role="navigation" id="nav-main" class="okayNav">
        <ul>
            <li><a href="/categories">All</a></li>
            {{ range $.Site.Taxonomies.categories.ByCount }}
                {{ if .Name }}
                <li><a href="/categories/{{ .Name | urlize}}/"> {{ .Name }}</a>
                {{ end }}
            {{ end}}
            </ul>
        </nav>
    </header>

    <div class="article-body">
        {{ range $.Site.Taxonomies.categories.ByCount }}
        <div class="panel panel-default b-no">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
            <a data-toggle="collapse" href="#collapse{{ .Name }}" aria-expanded="true">
                <i class="icon icon-folder text-active"></i><i class="icon icon-folder-open text"></i>
                {{ .Name }}
            </a>
            <small class="text-muted">(Total  {{ len .Pages }} articles)</small>
            </h4>
        </div>
        <div id="collapse{{ .Name }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading{{ .Name }}">
            <div class="panel-body">
            <div class="collection">
                {{ range .Pages }}
                <a href="{{ .URL }}" class="collection-item" target="_blank" itemprop="url">
                        <time>{{.Date.Format  "2006-01-02" }}</time>
                        <span>&nbsp;&nbsp;&nbsp;</span>{{ .Title }}
                    </a>
                {{ end }}
            </div>
            </div>
        </div>
        </div>
        {{ end }}
    </div>
</article>
{{ end }}
{{ end }}